import React from 'react';
import * as THREE from 'three';
import Scene from '../Scene';

export default class Light {
    constructor(){
        this.scene = new Scene();
        this.canvasScene = this.scene.scene;
        this.setLight();        
    }
    setLight(){
        // 添加主光源
        this.directionalLight = new THREE.DirectionalLight('#5ea5fa', 10);
        this.directionalLight.castShadow = false;
        this.directionalLight.shadow.camera.left = -10;
        this.directionalLight.shadow.camera.right = 10;
        this.directionalLight.shadow.camera.top = 10;
        this.directionalLight.shadow.camera.bottom = -10;
        this.directionalLight.shadow.camera.far = 40;
        this.directionalLight.shadow.mapSize.set(512, 512);
        this.directionalLight.shadow.normalBias = 0.05;
        this.directionalLight.position.set(0, 10, 8);
        this.canvasScene.add(this.directionalLight);
        // this.canvasScene.add(new THREE.DirectionalLightHelper(this.directionalLight));
        // let helper = new THREE.CameraHelper(this.directionalLight.shadow.camera);
        // this.canvasScene.add(helper);
        // 添加侧光源
        this.directionalLight2 = new THREE.DirectionalLight('#ffffff', 1);
        // this.directionalLight2.castShadow = true;
        this.directionalLight2.position.set(-15, 10, 8);
        this.canvasScene.add(this.directionalLight2);
        // this.canvasScene.add(new THREE.DirectionalLightHelper(this.directionalLight2));
        // 添加背光
        // this.directionalLight3 = new THREE.DirectionalLight('#ffffff', 0.2);
        // this.directionalLight2.castShadow = true;
        // this.directionalLight3.position.set(0, 8, -10);
        // this.canvasScene.add(this.directionalLight3);
        // 环境光
        const ambientLight = new THREE.AmbientLight('#ffffff', 0.1);
        this.canvasScene.add(ambientLight);
    }
}